<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>提现</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no"/>
	    <meta http-equiv="Access-Control-Allow-Origin" content="*">
	    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
		<link rel="stylesheet" href="../css/base.css" />
		<link rel="stylesheet" href="../css/tixian.css" />
		<script src="../js/jquery-2.2.3.min.js"></script>
		<script type="text/javascript" src="../js/rem.js"></script>
		<script src="../js/vue.min.js"></script>
		<script src="../js/vue-resource.min.js"></script>
		<script src="../js/common.js"></script>
		<style>
			.tixian_inp {
				border-bottom: 1px solid #CCCCCC !important;
				margin-top: .15rem;
				font-size: .18rem;
			}
			.tixian_btn {
				margin: .27rem auto;
			}
		</style>
	</head>
	<body>
	<div id="app">
		<div class="header">
			<a href="javascript:history.back(-1)"><img src="../img/g_next.png" alt="" /></a>
			提现
		</div>
		<div class="tixian_main">
			<div class="tixian_fangShi" onclick="window.location.href='bankCard1.html'">
				<!--<img class="FS" src="../img/g_tixian_wx.png" alt="" />-->
				<div class="name">
					<p class="two">{{yinhangka}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{yinhangka2}}</p>
				</div>
				<img class="right" src="../img/icon-right.png" alt="" />
			</div>
			<div class="tixian_jinE">
				<p class="tixian_TS">请输入提现金额</p>
				<input class="tixian_inp" type="text" placeholder="￥" />
				<!--<p class="tixian_XZ">本次可提现{{money}}元<span @click="cashWithdrawal">全部提现</span></p>-->
				<!--<p class="tixian_XZ">本次可提现{{money}}元<span @click="cashWithdrawal">全部提现</span></p>-->
			</div>
		</div>
		<!--<p class="tixian_DZ">提现免手续费，预计1-3个工作日到账</p>-->
		<input type="button" value="下一步" class="tixian_btn" />
		<div class="overlay">
			<!--<div class="tixian_FS_XZ">-->
				<!--<p class="title">提现到</p>-->
				<!--<ul class="tixian_FS_XZ_ul">-->
					<!--<li class="tixian_FS_XZ_li">-->
						<!--<img src="../img/g_tixian_afb.png" alt="" />-->
						<!--<span>支付宝账户（3756）</span>-->
					<!--</li>-->
					<!--<li class="tixian_FS_XZ_li">-->
						<!--<img src="../img/g_tixian_wx.png" alt="" />-->
						<!--<span>微信零钱</span>-->
					<!--</li>-->
					<!--<li class="tixian_FS_XZ_li" v-for="item in list" @click="tixian_FS_XZ_li" :data-id=item.bankCardId>
						<img src="../img/g_tixian_yh.png" alt="" />
						<span>{{item.bankName}}</span>
					</li>-->
				<!--</ul>-->
				<!--<div class="tixian_tj">-->
					<!--<img  src="../img/G_tixian_tj.png"/>-->
					<!--<span>添加新卡</span>-->
				<!--</div>-->
			<!--</div>-->
			<div class="tixian_password">
				<p class="title">输入支付密码</p>
				<img class="gb" src="../img/g_tixian_gb.png" alt="" />
				<div class="input f_l">
					<input class="MM inpVal1" style="border-left:1px solid #909090;" type="password" class="" maxlength="1">
					<input class="MM inpVal2" type="password" maxlength="1">
					<input class="MM inpVal3" type="password" maxlength="1">
					<input class="MM inpVal4" type="password" maxlength="1">
					<input class="MM inpVal5" type="password" maxlength="1">
					<input class="MM inpVal6" type="password" maxlength="1">
				</div>
				<a href="#" class="WJ_password">忘记密码?</a>
			</div>

		</div>
	</div>
	</body>
	<script>
		$(function(){
			// $('.tixian_fangShi').click(function(){
			// 	$('.overlay').show();
			// 	$('.tixian_FS_XZ').show();
			// });
            var _lv = 0.1;
            $('.tixian_XZ1 span').text(_lv * 100 + '%');
            $('.tixian_btn').click(function(){
                var ze = parseInt(localStorage.getItem('xianjinzonge'));
                if (parseInt($('.tixian_inp').val()) == 0) {
                    alert('提现金额不允许为0')
                }else if (parseInt($('.tixian_inp').val()) == '') {
                    alert('提现金额不允许为空')
                }else if (parseInt($('.tixian_inp').val()) <= ze) {
                    $('.overlay').show();
                    $('.tixian_password').show();
                }else {
                    alert('现金钱包余额不足');
                }
            });
            $('.tixian_inp').blur(function () {
                var _val = $(this).val();
                var sxf = _val * _lv;
                var num = _val - sxf;
                $(this).text(num);
            });
			/*$('.tixian_btn').click(function(){
				$('.overlay').show();
				$('.tixian_password').show();
			});*/
			$('.tixian_password .gb').click(function(){
				$('.overlay').hide();
			})

    })
</script>
<script>
	var _idi = '';
    var app = new Vue({
        el: '#app',
        data: {
            list: [],
            yinhangka: '',
            yinhangka2: '',
            yinhangka3: '',
            money: '',
            cash: '',
            bankCardId: '',
        },
        mounted() {

            var money = decodeURIComponent(getQueryString("money"));
            // console.log(money);
            // console.log(SURL);
            // console.log(localStorage.getItem('yh1'));
            // console.log(localStorage.getItem('yh2'));
            // console.log(localStorage.getItem('yh3'));
            // this.yinhangka = localStorage.getItem('yh2');
            // this.yinhangka2 = localStorage.getItem('yh3');
            this.money = money
            var getUrl = GetRequest();
            console.log(getUrl.bankCardId)
            if (getUrl.hasOwnProperty('bankCardId')) {
                this.$http.get(SURL + '/jfd/usersBankcards/getBankById?bankCardId='+getUrl.bankCardId
                ,{
                    emulateJSON: true
                }).then(function (res) {
                    console.log(res.body);
                    this.yinhangka = res.body.usersBankcard.accNo;
                    this.yinhangka2 = res.body.usersBankcard.bankName;
                    _idi = res.body.usersBankcard.bankCardId;
                })
            } else {
                this.yinhangka = '';
                this.yinhangka2 = '请选择银行卡';
                this.yinhangka3 = '';
            }
        },
        methods: {
            tixian_FS_XZ_li: function (event) {
                var _th = event.target
                console.log($(_th).find('span').html())
                // console.log($(_th).data('id'));
                if (!$(_th).data('id')) {
                    this.bankCardId = $(_th).parents('.tixian_FS_XZ_li').data('id')
                } else {
                    this.bankCardId = $(_th).data('id')
                }
                // if(!$(_th).find('span').html()){
                //    this.yinhangka = $(_th).parents('.tixian_FS_XZ_li').find('span').html();
                // }else {
                //    this.yinhangka = $(_th).html();
                // }
                $('.overlay').hide();
                this.yinhangka = $(_th).find('span').html();
                console.log(this.yinhangka)

            },
            cashWithdrawal: function () {
                this.cash = this.money
            }
        }
    })

    function GetRequest() {
        //获取url中"?"符后的字串 
        var url = location.search;
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
</script>
<script>
    /*模拟支付宝的密码输入形式*/
    (function (window, document) {
        var active = 0,
            inputBtn = document.getElementsByClassName('MM');
        for (var i = 0; i < inputBtn.length; i++) {
            inputBtn[i].addEventListener('click', function () {
                inputBtn[active].focus();
            }, false);
            inputBtn[i].addEventListener('focus', function () {
                this.addEventListener('keyup', listenKeyUp, false);
            }, false);
            inputBtn[i].addEventListener('blur', function () {
                this.removeEventListener('keyup', listenKeyUp, false);
            }, false);
        }

            /*监听键盘的敲击事件*/
            function listenKeyUp() {
                if(!isNaN(this.value) && this.value.length != 0) {
                    if(active < 5) {
                        console.log(active);
                        active += 1;
                    }else if(active == 5){
                        console.log(333);
                        var int  = document.getElementsByClassName('MM ')
                        var srt = ''
                        for(i =0;i<int.length;i++){
                            srt += int[i].value
                        }
                        console.log(srt);
                        console.log(this.yinhangka3);
                        $.ajax({
                            url: SURL + '/jfd/usersDraws/destoonFinanceCash',
                            type: 'POST',
                            data: {
                                userId: localStorage.getItem('userId'),
                                bankCardId: _idi,
                                cash: $('.tixian_inp').val(),
                                type: 1,
                                paypassword: srt
                            },
                            success: function (res) {
                                if (res.code == 0) {
                                    localStorage.setItem('xfje2', $('.tixian_inp').val());
                                    window.location.href = 'xianjintixianjieguo.html';
                                }else {
                                    alert(res.msg);
                                }
                            }
                        })
                    }
                    inputBtn[active].focus();
                } else if(this.value.length == 0) {
                    console.log(2222);
                    if(active > 0) {
                        active -= 1;
                    }
                    inputBtn[active].focus();
                }
            }


        })(window, document);

	</script>
</html>
